<!DOCTYPE html>
<html>
<head>
    <title>成都文理学院思想政治理论水平在线测试</title>
    <link rel="shortcut icon" href="../images/favicon.ico">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <link href="css/bootstrap.min.css" rel="stylesheet"
          type="text/css"/>
    <link href="css/theme.css" rel="stylesheet"
          type="text/css"/>
    <link href="css/sweetalert.css" rel="stylesheet"
          type="text/css"/>
    <script src="../js/jquery-3.3.1.js"></script>
    <script src="js/bootstrap.min.js" rel="stylesheet"
            media="screen"></script>
    <script src="js/sweetalert.min.js" rel="stylesheet"
            media="screen"></script>
    <script type="text/javascript" src="js/layer/layer.js"></script>
    <style>
        body {
            -moz-user-select: none;
            -webkit-user-select: none;
            -ms-user-select: none;
            -khtml-user-select: none;
            user-select: none;
        }

        .cssfont1 {
            font-size: 31px;
            margin-top: -7px;
            color: red;
            font-family: 宋体;
        }

        .cssfont2 {
            font-size: 12.5px
        }

        /* .btn{
             width:20px;


         }*/
    </style>

</head>
<script >
    var currentTime;
    $(document).ready(function () {
        $.post(projectName+"/examinee/currentTime.do",
            function (data) {
               // console.log("======"+data);
                currentTime=data;
            },
            "text"
        );
    });
</script>
<body oncontextmenu = "return false" >
<div align="center" style="background-color: White">
    <img src="images/logo.png"/>
</div>
<div class="row-fluid">
    <div class="container-fluid">
        <div class="span4 examcontent" style="width:280px">
            <div class="exambox">
                <div class="examform">
                    <ul class="unstyled">
                        <li>
                            <h6>
                                <div class="cssfont2">

                                    &nbsp;1. 共<span  class="allquestionnumber"></span>题，总分：<span class="orange total-score">100</span>分&nbsp;&nbsp; <br/>
                                    &nbsp;2. 合格分数线：<span class="pass"></span>分&nbsp;&nbsp;   <br/>
                                    &nbsp;3. 考试时间：
                                    <sapn class="examTime"></sapn>
                                    分钟
                                </div>
                            </h6>
                        </li>
                    </ul>
                    <h5 class="title" id="dan-title" style="display: none">
                        单选题</h5>
                    <ul class="unstyled inline dan">

                        <!--<a id="btn_1" class="btn" style="width: 20px;" type="dan1"
                           onclick="selectTest(this,1)">1</a>

                        <a id="btn_${status.index+1 }" class="btn btn-primary" style="width: 20px;"
                           onclick="selectTest(${status.index+1 },${qo.resultId })">2</a>

                            <a id="btn_${status.index+1 }" class="btn btn-primary" style="width: 20px;"
                           onclick="selectTest(${status.index+1 },${qo.resultId })">3</a>-->

                    </ul>


                    <h5 class="title" id="duo-title" style="display: none">
                        多选题</h5>
                    <ul class="unstyled inline duo">

                        <!-- <a id="btn_${status.index+1 }" class="btn " style="width: 20px;" type="duo"
                             onclick="selectTest(this,4)">4</a>

                          <a id="btn_${status.index+1 }" class="btn btn-primary" style="width: 20px;"
                             onclick="selectTest(${status.index+1 },${qo.resultId })">5</a>
                             -->
                    </ul>
                    <h5 class="title" id="pan-title" style="display: none">
                        判断题</h5>
                    <ul class="unstyled inline pan">

                        <!-- <a id="btn_${status.index+1 }" class="btn" style="width: 20px;"
                            onclick="selectTest(${status.index+1 },${qo.resultId })">6</a>

                         <a id="btn_${status.index+1 }" class="btn btn-primary" style="width: 20px;"
                            onclick="selectTest(${status.index+1 },${qo.resultId })">7</a>-->

                    </ul>

                    <h5 class="title" id="tian-title" style="display: none">
                        填空题</h5>
                    <ul class="unstyled inline tian">

                        <!-- <a id="btn_${status.index+1 }" class="btn" style="width: 20px;"
                            onclick="selectTest(${status.index+1 },${qo.resultId })">6</a>

                         <a id="btn_${status.index+1 }" class="btn btn-primary" style="width: 20px;"
                            onclick="selectTest(${status.index+1 },${qo.resultId })">7</a>-->

                    </ul>
                </div>
            </div>
        </div>
        <div class="span8 examcontent">
            <div class="exambox">
                <div class="examform">
                    <div class="cssfont1" style="text-align: center;font-size:24px"><b class="examName">132</b></div>
                    <div class="container-fluid footcontent">

                        <div class="span7">
                            <ul class="unstyled">
                                <!--<div class="cssfont1"><b class="examName">132</b></div>-->
                                <li>
                                    <h6>
                                        编号：<span class="number">${user_in_session.idx}</span><br/>
                                        姓名：<span class="name">${user_in_session.name}</span><br/>
                                        年级专业：<span class="grade">${user_in_session.grade</span><span class="major">${user_in_session.major}</span><br/>
                                        <h4>
                                            距考试结束：<span class="orange" id="time" style="color:red"></span></h4>
                                    </h6>
                                </li>
                            </ul>
                        </div>
                        <div class="span3">
                            <ul class="unstyled">
                                <li>
                                    <!--<h4>-->
                                        <!--距考试结束：<span class="orange" id="time" style="color:red"></span></h4>-->
                                </li>
                            </ul>
                        </div>
                        <div class="span2">
                            <a style="float: right" id="submitExam" class="btn btn-danger" onclick="advanceSubmit()" id="submit">交卷</a>
                        </div>
                    </div>
                    <div class="paperexamcontent" id="question_396">


                        <div id="question" style="display:block;margin-top: 15px"
                             class="media well ">
                            <!--<h4 class="type">单选题（每题有且只有一个选项）</h4>
                            <div class="media-body well " style="font-weight: bold;color: black;">
                                <h4 id="">1.请问下道题选择什么？</h4>
                            </div>
                            <div class="media-body well " style="color: black;">
                               <p>
                                    A、${q.optionA }</p>
                                <p>
                                    B、${q.optionB }</p>
                                <p>
                                    C、${q.optionC }</p>
                                <p>
                                    D、${q.optionD }</p>

                            </div>
                           <div class="media-body well">
                                <label class=" radio inline ">
                                   <input type="radio"

                                           name=danxuan"" value="A">A
                                </label>
                                <label class="radio inline">
                                   <input type="radio"

                                           name="danxuan_${status.index }" value="B">B
                                </label>
                                <label class="radio inline">
                                    <input type="radio"

                                           name="danxuan_${status.index }" value="C">C
                                </label>
                                <label class="radio inline">
                                   <input type="radio"

                                           name="danxuan_${status.index }" value="D">D
                                </label>
                            </div>
                           -->


                            <!-- <h4 class="">不定项选择（每题有一个或者多个选项）</h4>
                             <div class="media-body well " style="font-weight: bold;color: black;">
                                 <h4> 请问下道题选择什么？</h4>
                             </div>
                             <div class="media-body well" style="color: black;">
                                 <p>
                                     A、${q.optionA }</p>
                                 <p>
                                     B、${q.optionB }</p>
                                 <p>
                                     C、${q.optionC }</p>
                                 <p>
                                     D、${q.optionD }</p>
                             </div>
                             <div class="media-body well">

                                 <label class="checkbox inline">
                                     <input type="checkbox"

                                            name="duoxuanA" value="A"/>A
                                 </label>
                                 <label class="checkbox inline">
                                     <input type="checkbox"

                                            name="duoxuanB" value="B"/>B
                                 </label>
                                 <label class="checkbox inline">
                                     <input type="checkbox"

                                            name="duoxuanC" value="C"/>C
                                 </label>
                                 <label class="checkbox inline">
                                     <input type="checkbox"

                                            name="duoxuanD" value="D"/>D
                                 </label>
                             </div>-->


                            <!--
                             <h4 class="">判断题</h4>
                             <div class="media-body well " style="font-weight: bold;color: black;">
                                 //题的顺序编号
                                 <h4> ${ status.index+1}.${q.intro}</h4>
                             </div>
                             <div class="media-body well" style="color: black;">
                                 <label class="radio inline">
                                     <input type="radio"

                                            name="panduan_${status.index }" value="A">对
                                 </label>
                                 <label class="radio inline">
                                     <input type="radio"

                                            name="panduan_${status.index }" value="B"/>错
                                 </label>
                             </div> -->
                            <ul>
                                <li class="btn-group pull-right">
                                    <a class="btn" id="last">上一题</a>
                                    <a class="btn btn-info" id="next">下一题</a>
                                </li>
                            </ul>

                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<input type="hidden" id="currentTime" value=""/>
<div class="row-fluid">
    <div class="container-fluid logfooter">
        <ul class="inline unstyled" style="background-color: white;">
            <!--  <li><a href="http://phpems.net">成都文理学院党校</a></li>-->
            <li><a id="about" href="#">成都文理学院党校</a></li>
        </ul>
    </div>
</div>
<script type="text/javascript">
    function submitExam() {
        $.ajax({
            type: "get",
            url: projectName+"/examinee/updateEndTime.do",
            async: false,
            dataType: "json",
            success: function (res) {
                if (res) {
                    layer.msg("交卷成功", {icon: 1, time: 1000}, function () {
                        window.location.href = 'score.html';
                    });
                } else {
                    layer.msg("交卷失败,请联系管理员!", {icon: 1, time: 1000}, function () {
                        window.location.href = 'score.html';
                    });
                }

            }
        });
    }

    document.getElementById("submitExam").onclick = submitExam;
    var data;
    var examStartTime;
    var examTime;
    window.onload = function () {
        $.ajax({
            type: "get",
            dataType: "json",
            url: projectName+"/examinee/allQuestionInfoForStu.do",
            success: function (result) {
                var msg = result;
              //  console.log(msg);
                var count = msg.countQue;
                var pass = msg.pass;
                examTime = msg.examTime;
                var examName = msg.examName;
                var number = msg.number;
                var name = msg.name;
                var grade = msg.grade;
                var major = msg.major;
                examStartTime = msg.examStartTime;
                var timeId = window.setInterval(sessionTimeout, 1000);
                //渲染考生 基本信息
                $(".allquestionnumber").text(count);
                $(".pass").text(pass);
                $(".examTime").text(examTime);
                $(".examName").text(examName);
                $(".number").text(number);
                $(".name").text(name);
                $(".grade").text(grade);
                $(".major").text(major);
                $(".total-score").text(msg.totalScore);
                //获取考试题型以及题量
                var danTotal = msg.danTotal;
                var duoTotal = msg.duoTotal;
                var panTotal = msg.panTotal;
                var tianTotal = msg.tianTotal;

                if (danTotal != 0) {
                  document.getElementById("dan-title").style.display="block";
                    for (var i = 0; i < danTotal; i++) {
                        var dan = "<a style='width:20px;margin-left:4px;margin-top:3px;' id='btn_" + (i + 1) + "' class='btn'>" + (i + 1) + "</a>";
                        $(".dan").append(dan);

                        //"<input type='radio' name='dan_"+(parseInt(i)+1)+"'value='A'>A"+
                    }
                }
                if (duoTotal != 0) {
                    document.getElementById("duo-title").style.display="block";
                    for (var i = 0; i < duoTotal; i++) {
                        var duo = "<a style='width:20px;margin-left:4px;margin-top:3px;' id='btn_" + (i + 1 + danTotal) + "' class='btn' onclick='selectTest(this,1)'>" + (i + 1 + danTotal) + "</a>";
                        $(".duo").append(duo);
                    }
                }
                if (panTotal != 0) {
                    document.getElementById("pan-title").style.display="block";
                    for (var i = 0; i < panTotal; i++) {
                        var pan = "<a style='width:20px;margin-left:4px;margin-top:3px;' id='btn_" + (i + 1 + danTotal + duoTotal) + "' class='btn'  onclick='selectTest(this,1)'>" + (i + 1 + danTotal + duoTotal) + "</a>";
                        $(".pan").append(pan);
                    }
                }
                if (tianTotal != 0) {
                    document.getElementById("tian-title").style.display="block";
                    for (var i = 0; i < tianTotal; i++) {
                        var tian = "<a style='width:20px;margin-left:4px;margin-top:3px;' id='btn_" + (i + 1 + danTotal + duoTotal + panTotal) + "' class='btn' onclick='selectTest(this,1)'>" + (i + 1 + danTotal + duoTotal + panTotal) + "</a>";
                        $(".tian").append(tian);
                    }
                }
                var dan;
                var duo;
                var pan;
                var tian;
                $.each(msg, function (index, item) {
                    //渲染单选题
                    if (index == "dan") {
                        dan = item;

                        for (var i in dan) {
                            //渲染每道题画面开始
                            var questionList = "<div id='dan" + (parseInt(i) + 1) + "'style='display:none' class='d'><h4 class='type'>单选题</h4>" +
                                "            <div class='media-body well' style='font-weight: bold;color: black;'>" +
                                "                <h4 id=''>" + (parseInt(i) + 1) + ". " + dan[i].intro + "</h4>" +
                                "            </div>" +
                                "            <div class='media-body well' style='color: black;'>" +
                                "               <p>" +
                                "                    A. " + dan[i].optionA + "</p>" +
                                "                <p>" +
                                "                    B. " + dan[i].optionB + "</p>" +
                                "                <p>" +
                                "                   C. " + dan[i].optionC + "</p>" +
                                "                <p>" +
                                "                    D. " + dan[i].optionD + "</p>" +
                                "            </div>" +
                                "           <div class='media-body well'>" +
                                "                <label class='radio inline'>" +
                                "                  <input type='radio' id=" + dan[i].id + " name='dan_" + (parseInt(i) + 1) + "'value='A'>A" +
                                "               </label>" +
                                "                <label class='radio inline'>" +
                                "                  <input type='radio' id=" + dan[i].id + " name='dan_" + (parseInt(i) + 1) + "' value='B'>B" +
                                "               </label>" +
                                "                <label class='radio inline'>" +
                                "                  <input type='radio' id=" + dan[i].id + " name='dan_" + (parseInt(i) + 1) + "' value='C'>C" +
                                "               </label>" +
                                "                <label class='radio inline'>" +
                                "                  <input type='radio' id=" + dan[i].id + " name='dan_" + (parseInt(i) + 1) + "' value='D'>D" +
                                "               </label></div>";
                            $("#question").append(questionList);
                        }
                    }
                    //渲染多选题

                    if (index == "duo") {
                        duo = item;

                        for (var i in duo) {

                            var questionList = "<div id='duo" + (parseInt(i) + 1 + danTotal) + "'style='display:none' class='d'><h4 class='type'>多选题</h4>" +
                                "            <div class='media-body well' style='font-weight: bold;color: black;'>" +
                                "                <h4 id=''>" + (parseInt(i) + 1 + danTotal) + ". " + duo[i].intro + "</h4>" +
                                "            </div>" +
                                "            <div class='media-body well' style='color: black;'>" +
                                "               <p>" +
                                "                    A. " + duo[i].optionA + "</p>" +
                                "                <p>" +
                                "                    B. " + duo[i].optionB + "</p>" +
                                "                <p>" +
                                "                   C. " + duo[i].optionC + "</p>" +
                                "                <p>" +
                                "                    D. " + duo[i].optionD + "</p>" +
                                "            </div>" +
                                "           <div class='media-body well'>" +
                                "                <label class='checkbox inline'>" +
                                "                  <input type='checkbox' id=" + duo[i].id + " name='duo_" + (parseInt(i) + 1 + danTotal) + "'value='A'>A " +
                                "               </label>" +
                                "                <label class='checkbox inline'>" +
                                "                  <input type='checkbox' id=" + duo[i].id + " name='duo_" + (parseInt(i) + 1 + danTotal) + "' value='B'>B" +
                                "               </label>" +
                                "                <label class='checkbox inline'>" +
                                "                  <input type='checkbox' id=" + duo[i].id + " name='duo_" + (parseInt(i) + 1 + danTotal) + "' value='C'>C" +
                                "               </label>" +
                                "                <label class='checkbox inline'>" +
                                "                  <input type='checkbox' id=" + duo[i].id + " name='duo_" + (parseInt(i) + 1 + danTotal) + "' value='D'>D" +
                                "               </label></div>";
                            $("#question").append(questionList);

                        }
                    }


                    if (index == "pan") {
                        pan = item;

                        for (var i in pan) {

                            var questionList = "<div id='pan" + (parseInt(i) + 1 + danTotal + duoTotal) + "'style='display:none' class='d'><h4 class='type'>判断题</h4>" +
                                "            <div class='media-body well' style='font-weight: bold;color: black;'>" +
                                "                <h4 id=''>" + (parseInt(i) + 1 + danTotal + duoTotal) + ". " + pan[i].intro + "</h4>" +
                                "            </div>" +
                                "            <div class='media-body well' style='color: black;'>" +
                                "               <p>" +
                                "                    A. " + pan[i].optionA + "</p>" +
                                "                <p>" +
                                "                    B. " + pan[i].optionB + "</p>" +
                                "                <p>" +
                                // "                   C、"+duo[i].optionC+"</p>"+
                                // "                <p>"+
                                // "                    D、"+duo[i].optionD+"</p>"+
                                "            </div>" +
                                "           <div class='media-body well'>" +
                                "                <label class='radio inline'>" +
                                "                  <input type='radio' id=" + pan[i].id + "  name='pan_" + (parseInt(i) + 1 + danTotal + duoTotal) + "'value='A'>A " +
                                "               </label>" +
                                "                <label class='radio inline'>" +
                                "                  <input type='radio' id=" + pan[i].id + " name='pan_" + (parseInt(i) + 1 + danTotal + duoTotal) + "' value='B'>B" +
                                "               </label>";
                            // "                <label class='radio inline'>"+
                            // "                  <input type='radio' name='pan_"+(parseInt(i)+1+danTotal+duoTotal)+"' value='C'>C"+
                            // "               </label>"+
                            // "                <label class='radio inline'>"+
                            // "                  <input type='radio' name='pan_"+(parseInt(i)+1+danTotal+duoTotal)+"' value='D'>D"+
                            // "               </label></div>";
                            $("#question").append(questionList);

                        }
                    }

//渲染填空题
                    if (index == "tian") {
                        tian = item;
                        for (var i in tian) {
                            var questionList = "<div id='tian" + (parseInt(i) + 1 + danTotal + duoTotal + panTotal) + "'style='display:none' class='d t'><h4 class='type'>填空题</h4>" +
                                "            <div class='media-body well' style='font-weight: bold;color: black;'>" +
                                "                <h4 id=''>" + (parseInt(i) + 1 + danTotal + duoTotal + panTotal) + ". " + tian[i].intro + "</h4>" +
                                "            </div>" +

                                "</div>";

                            $("#question").append(questionList);

                        }
                    }


                });
                //渲染填空题button

                var list = document.getElementsByTagName("input");
                // console.log(list[i].name);
                var buttonList = $(".btn");
                var danDiv = $(".d");
               // console.log(buttonList);
                //为每个input绑定值
                for (var i = 0; i < list.length; i++) {
                    list[i].onclick = function () {
                        if (this.name.split("_")[0] == "dan" || this.name.split("_")[0] == "pan") {
                            //console.log(this.checked);
                            var index = this.name.split("_")[1];
                            $("#btn_" + index).attr("class", "btn btn-primary");
                            //发送ajax将答案发送到后台
                            $.ajax({
                                type: "POST",
                                url: projectName+"/examinee/updateByQueId.do",
                                async: false,
                                dataType: "json",
                                data: {id: this.id, answer: this.value},
                                success: function (res) {
                                    console.log('发送成功')
                                }
                            });

                        }

                        //针对多选按钮
                        if (this.name.split("_")[0] == "duo") {
                            var current = $("input[name='" + this.name + "']:checked").val();
                          //  console.log(current);
                            if (current == undefined) {
                                var index = this.name.split("_")[1];
                                $("#btn_" + index).attr("class", "btn");
                            } else {
                                var index = this.name.split("_")[1];
                                $("#btn_" + index).attr("class", "btn btn-primary");
                            }
                            var selected = $("input[name='" + this.name + "']:checked");
                            var answer = '';
                            //循环选中的每一项的值
                            selected.each(function () {
                                answer += this.value;
                            })
                          //  console.log(answer)
                            $.ajax({
                                type: "POST",
                                url: projectName+"/examinee/updateByQueId.do",
                                async: false,
                                dataType: "json",
                                data: {id: this.id, answer: answer},
                                success: function (res) {
                                    console.log('发送成功')
                                }
                            });


                        }


                    }
                }
                //为每个选择绑定按钮
                for (var i = 0; i < buttonList.length - 3; i++) {
                    buttonList[i].onclick = function () {
                        var index = this.id.split("_")[1];
                       // console.log(index);
                        $(".d").css("display", "none");
                        $(danDiv[index - 1]).css("display", "block");


                    }

                }

                //回显所有的单选按钮
                //1、获取所有的单选按钮
                var danList = $("input:radio");

                var k = 0;
                for (var i in dan) {
                    //循环四次，因为每道题有四个答案
                    for (var j = 1; j <= 4; j++) {
                        if (danList[k].value == dan[i].result) {
                            $(danList[k]).attr("checked", true);
                        }
                        k = k + 1;
                    }
                }
                //回显判断题
                for (var i in pan) {
                    //循环四次，因为每道题有四个答案
                    for (var j = 1; j <= 2; j++) {
                        if (danList[k].value == pan[i].result) {
                            $(danList[k]).attr("checked", true);
                            //console.log("判断题回显"+danList[x].checked)
                        }
                        k = k + 1;
                    }
                }


                //回显所有的多选按钮
                //1、获取所有的多选按钮
                var duoList = $("input:checkbox");
                var m = 0;
                for (var i in duo) {
                    for (var j = 1; j <= 4; j++) {

                        for (var l = 0; l < duo[i].result.length; l++) {
                            if (duoList[m].value == duo[i].result.charAt(l)) {
                                $(duoList[m]).attr("checked", true);
                            }
                        }
                        m = m + 1;
                    }
                }
                //回显所有的填空题
                var tianList = $(".t");

                for (var i in tian) {
                    // console.log(tianList[i].id)
                    // var str=tian[i].result
                    // var regex=/\{(.+?)}/g;
                    // var arr =str.match(regex);
                    //
                    // console.log(arr);
                    // var newArr =[];
                    // var text='';
                    var str = tian[i].result
                    var newArr = [];
                    var text = '';
                    var arr = str.split("}{");
                    arr[0] = arr[0].substring(1);
                    arr[arr.length - 1] = arr[arr.length - 1].substring(0, arr[arr.length - 1].length - 2);
                  //  console.log(arr);
                    for (j = 0; j < arr.length; j++) {
                        var n = arr[j].substring(1, arr[j].length - 1).trim();
                        text += "<input type='text' id=" + tian[i].id + " name='tian_" + (danTotal + duoTotal + panTotal + parseInt(i) + 1) + "' value=" + arr[j] + ">";
                        newArr.push(arr[j]);
                    }
                  //  console.log(newArr)
                    var isNull = ''
                    newArr.forEach(function (item) {
                        isNull += item;
                    })
                   // console.log(isNull)
                    //       console.log(isNull)
                    //         if(isNull==""){newArr=[]}

                    if (isNull != []) {
                        //   console.log(tian[i].id);
                        //  console.log();
                        //  var index =
                        // var index=$("#"+tian[i]).attr("name");
                        // index =index.split("_")[1]
                        //console.log(index+"test");
                        $("#btn_" + (danTotal + duoTotal + panTotal + parseInt(i) + 1)).attr("class", "btn btn-primary");

                    }


                    //   console.log(i);
                    $('#' + tianList[i].id).append(text)

                }


                //获取所有的填空题文本框

                var tianText = $("input[type='text']");
                for (var i = 0; i < tianText.length; i++) {
                    tianText[i].onblur = function () {
                        var filled = $("input[name='" + this.name + "']");
                        var fillAnswer = '';
                        var value = '';
                        //console.log(this.name.split[])
                        filled.each(function () {

                            fillAnswer += "{" + this.value + "}";

                            value += this.value

                        })
                        var index = this.name.split("_")[1];
                        if (value != "") {
                            $("#btn_" + index).attr("class", "btn btn-primary");
                        } else {
                            $("#btn_" + index).attr("class", "btn");
                        }

                        $.ajax({
                            type: "POST",
                            url: projectName+"/examinee/updateByQueId.do",
                            async: false,
                            dataType: "json",
                            data: {id: this.id, answer: fillAnswer},
                            success: function (res) {
                            //    console.log('发送成功')
                            }
                        });


                    }

                }


                //代码执行到这里时，题的数据以及做题记录渲染完毕，开始对页面进行逻辑性操作
                //获取所有的input

                //默认第一题显示
                $("#dan1").css("display", "block");
                var all = $("input:checked");
                for (var i = 0; i < all.length; i++) {
                   // console.log(all[i].name.split("_")[1]);
                    if (all[i].name.split("_")[1] == (i + 1)) ;
                    $("#btn_" + all[i].name.split("_")[1]).attr("class", "btn btn-primary");

                }
            }

        });

        var index = 1;

        //下一题
        $("#next").click(function () {

            var d = $(".d");

            for (var i = 0; i < d.length; i++) {

                if ($(d[i]).css("display") == "block") {
                    //如果已经是最后一道题的话，点击则无效
                    if (i == d.length - 1) {
                        return;
                    }
                   // console.log(d[i]);
                    $(".d").css("display", "none");

                    $(d[i + 1]).css("display", "block");
                  //  console.log(d[i]);
                    return;
                }
            }
        });
        //上一题
        $("#last").click(function () {

            var d = $(".d");

            for (var i = 0; i < d.length; i++) {

                if ($(d[i]).css("display") == "block") {
                    //如果已经是第一道题的话，点击则无效
                    if (i == 0) {
                        return
                    }
                    ;
                   // console.log(d[i]);
                    $(".d").css("display", "none");

                    $(d[i - 1]).css("display", "block");
                   // console.log(d[i]);

                }
            }
        });

    };

</script>
<script type="application/javascript">
    // var timeId = window.setInterval(sessionTimeout, 1000);
    var flag = 0;
    //倒计时
    function sessionTimeout() {
        // var examStartTime;
        // var examTime;
        //console.log(examStartTime);
        //剩余秒数
        if (flag == 0) {
           // console.log( examTime * 60);
            //剩余秒数
            // window.second1 = examTime * 60 - Math.ceil((new Date().getTime() - examStartTime) / 1000);
            // console.log("currentTime:"+currentTime);
            // console.log("examStartTime"+examStartTime);
            window.second1 = examTime * 60 - Math.ceil((currentTime - examStartTime) / 1000);
            // console.log("当前时间戳:"+ currentTime );
            // console.log("开始考试时间戳:"+ examStartTime );
            // console.log("考试剩余考试分钟:"+ examTime * 60);
            // console.log("考试剩余考试秒数:"+ window.second1);
            flag=1;
        }
        --window.second1;
        var temp=window.second1%60>=10?window.second1%60:"0"+window.second1%60;
        var t=parseInt(window.second1/60)+":"+temp;
        $("#time").text(t);
        if(window.second1<=0)
        {
            // label.value="考试结束"
                //layer
                /* layer.confirm('时间到！', {
                icon:6,
                btn: ['确定'] //按钮
                }, function(){
                submit();
                }); layer非阻塞。。。。*/
                submitExam();
                clearInterval(timeId)
                alert("时间到！");
        }

    }

</script>

<script language="javascript">
    $("#about").click(function () {
        layer.open({
            type: 2,
            title: "关于开发团队",
            shadeClose: true,

            shade: [0.8, '#393D49'],
            shadeClose: false, //开启遮罩关闭
            maxmin: false, //开启最大化最小化按钮
            area: ['800px', '530px'],
            content: projectName+'/about.html'
            // });
            //   }
        });
    });
    if(localStorage.getItem("openOrClose")==1){
        document.body.style.userSelect="text"
    }
    //防止页面后退
    history.pushState(null, null, document.URL);
    window.addEventListener('popstate', function () {
        history.pushState(null, null, document.URL);
    });
</script>

</body>
</html>

